<?php
namespace App\Models\User;

use App\Models\Model;
use App\Models\Traits\Relation\Users\UsersRelation;

class Users extends Model {
    use UsersRelation;

    /**
     * 定义关联模型表
     * @var string
     */
    protected $table = 'users';

    /**
     * 定义不可填充字段
     *
     * @var array
     * Date: 2018-11-19
     * @author zx
     */
    protected $guarded = ['id'];

    /**
     * 表名模型是否应该被打上时间戳
     * @var  bool
     * @author zx
     */
//    public $timestamps = false;

    /**
     * 获取最高的账号值
     *
     * @author zx
     * @date 2018-11-21
     * @return int
     */
    public function getLastNumber():int
    {
        $number = self::select("number")
            ->orderBy("number", "desc")
            ->first();
        if($number && $number->number){
            return $number->number+1;
        }
        return 13200001;
    }
}